package com.aiyige.model.request;

import com.aiyige.base.api.ApiManager;

import java.util.List;

import okhttp3.ResponseBody;
import retrofit2.Call;

/**
 * Created by zhuyakun on 2017/11/20.
 */

public class PublishArticleRequest {
    public long categoryId;
    public String cover;
    public String title;
    public String detail;
    public String city;
    public double lng;
    public double lat;
    public List<Long> tagIds = null;
    public List<Article> articles = null;
    public List<Media> medias = null;

    private PublishArticleRequest(Builder builder) {
        setCategoryId(builder.categoryId);
        setCover(builder.cover);
        setTitle(builder.title);
        setDetail(builder.detail);
        setCity(builder.city);
        setLng(builder.lng);
        setLat(builder.lat);
        setTagIds(builder.tagIds);
        setArticles(builder.articles);
        setMedias(builder.medias);
    }

    public static Builder newBuilder() {
        return new Builder();
    }


    public long getCategoryId() {
        return categoryId;
    }

    public void setCategoryId(long categoryId) {
        this.categoryId = categoryId;
    }

    public String getCover() {
        return cover;
    }

    public void setCover(String cover) {
        this.cover = cover;
    }

    public String getTitle() {
        return title;
    }

    public void setTitle(String title) {
        this.title = title;
    }

    public String getDetail() {
        return detail;
    }

    public void setDetail(String detail) {
        this.detail = detail;
    }

    public String getCity() {
        return city;
    }

    public void setCity(String city) {
        this.city = city;
    }

    public double getLng() {
        return lng;
    }

    public void setLng(double lng) {
        this.lng = lng;
    }

    public double getLat() {
        return lat;
    }

    public void setLat(double lat) {
        this.lat = lat;
    }

    public List<Long> getTagIds() {
        return tagIds;
    }

    public void setTagIds(List<Long> tagIds) {
        this.tagIds = tagIds;
    }

    public List<Article> getArticles() {
        return articles;
    }

    public void setArticles(List<Article> articles) {
        this.articles = articles;
    }

    public List<Media> getMedias() {
        return medias;
    }

    public void setMedias(List<Media> medias) {
        this.medias = medias;
    }

    public static class Media {
        public static final int MEDIA_TYPE_VIDEO = 0;
        public static final int MEDIA_TYPE_PHOTO = 1;
        public String url;
        public String title;
        public long type;
        public long orderMe;

        public String getUrl() {
            return url;
        }

        public void setUrl(String url) {
            this.url = url;
        }

        public String getTitle() {
            return title;
        }

        public void setTitle(String title) {
            this.title = title;
        }

        public long getType() {
            return type;
        }

        public void setType(long type) {
            this.type = type;
        }

        public long getOrderMe() {
            return orderMe;
        }

        public void setOrderMe(long orderMe) {
            this.orderMe = orderMe;
        }
    }

    public static class Article {
        public static final int FONT_STYLE_BIG_TITLE = 1;
        public static final int FONT_STYLE_SMALL_TITLE = 2;
        public static final int FONT_STYLE_MAIN_BODY = 3;

        public String content;
        public String title;
        public long orderMe;
        public int fontStyle;

        public String getContent() {
            return content;
        }

        public void setContent(String content) {
            this.content = content;
        }

        public String getTitle() {
            return title;
        }

        public void setTitle(String title) {
            this.title = title;
        }

        public long getOrderMe() {
            return orderMe;
        }

        public void setOrderMe(long orderMe) {
            this.orderMe = orderMe;
        }

        public int getFontStyle() {
            return fontStyle;
        }

        public void setFontStyle(int fontStyle) {
            this.fontStyle = fontStyle;
        }
    }

    public static final class Builder {
        private long categoryId;
        private String cover;
        private String title;
        private String detail;
        private String city;
        private double lng;
        private double lat;
        private List<Long> tagIds;
        private List<Article> articles;
        private List<Media> medias;

        private Builder() {
        }

        public Builder categoryId(long categoryId) {
            this.categoryId = categoryId;
            return this;
        }

        public Builder cover(String cover) {
            this.cover = cover;
            return this;
        }

        public Builder title(String title) {
            this.title = title;
            return this;
        }

        public Builder detail(String detail) {
            this.detail = detail;
            return this;
        }

        public Builder city(String city) {
            this.city = city;
            return this;
        }

        public Builder lng(double lng) {
            this.lng = lng;
            return this;
        }

        public Builder lat(double lat) {
            this.lat = lat;
            return this;
        }

        public Builder tagIds(List<Long> tagIds) {
            this.tagIds = tagIds;
            return this;
        }

        public Builder articles(List<Article> articles) {
            this.articles = articles;
            return this;
        }

        public Builder medias(List<Media> medias) {
            this.medias = medias;
            return this;
        }

        public Call<ResponseBody> build() {
            return ApiManager.getService().publishArticle(new PublishArticleRequest(this));
        }
    }
}
